package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    RpcClientProxy rpcClientProxy;

    @RequestMapping("findUserById")
    public User findUserById(int id){

        IUserService userService = (IUserService) rpcClientProxy.createProxy(IUserService.class);

        User user = userService.getById(id);
        System.out.println(user);

        return user;
    }
}
